home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CICA Windows Explosion!
/
The CICA Windows Explosion! - Disc 2.iso
/
programr
/
ole2book.zip
/
CHAP07.ZIP
/
CHAP07
/
PATRON
/
PAGES.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-07
|
12KB
|
375 lines
/*
* PAGES.H
* Modifications for Chapter 7
*
* Definitions and function prototypes for the Pages window control
* as well as the CPage and CTenant classes.
*
* Copyright (c)1993 Microsoft Corporation, All Rights Reserved
*
* Kraig Brockschmidt, Software Design Engineer
* Microsoft Systems Developer Relations
*
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#ifndef _PAGES_H_
#define _PAGES_H_
//We need this for UICursorLoad and new-style cursors.
#include <bttncur.h>
//Versioning.
#define VERSIONMAJOR 2
#define VERSIONMINOR 0
#define VERSIONCURRENT 0x00020000
//Classname
#define SZCLASSPAGES "pages"
#define HIMETRIC_PER_INCH 2540
#define LOMETRIC_PER_INCH 254
#define LOMETRIC_BORDER 60 //Border around page
//Window extra bytes and offsets
#define CBPAGESWNDEXTRA (sizeof(LONG))
#define PAGEWL_STRUCTURE 0
//CHAPTER7MOD
/*
* Tenant class describing an individual piece of data in a page.
* It knows where it sits, what object is inside of it, and what
* its idenitifer is such that it can find it's storage within a page.
*/
//Patron Objects clipboard format
typedef struct tagPATRONOBJECT
{
POINTL ptl; //Location of object
POINTL ptlPick; //Pick point from drag-drop operation.
SIZEL szl; //Extents of object (absolute)
FORMATETC fe; //Actual object format.
} PATRONOBJECT, FAR * LPPATRONOBJECT;
//Values for hit-testing, drawing, and resize-tracking tenants
#define CXYHANDLE 5
//Tenant creation types (not persistent)
typedef enum
{
TENANTTYPE_NULL=0,
TENANTTYPE_STATIC,
} TENANTTYPE, FAR * LPTENANTTYPE;
//State flags
#define TENANTSTATE_DEFAULT 0x00000000
#define TENANTSTATE_SELECTED 0x00000001
class __far CTenant
{
private:
HWND m_hWnd; //Pages window, same as CPages.
DWORD m_dwID; //Persistent DWORD identifier
DWORD m_cOpens; //Count calls to FOpen.
BOOL m_fInitialized; //Something here?
LPUNKNOWN m_pObj; //The object that lives here.
LPSTORAGE m_pIStorage; //Sub-storage for this tenant
FORMATETC m_fe; //As used to create the object.
DWORD m_dwState; //State flags
RECTL m_rcl; //Space of this object.
class CPages FAR *m_pPG; //Pages window
protected:
HRESULT CreateStatic(LPDATAOBJECT, LPFORMATETC, LPUNKNOWN FAR *);
public:
CTenant(DWORD, HWND, CPages FAR *);
~CTenant(void);
DWORD GetID(void);
UINT GetStorageName(LPSTR);
UINT UCreate(TENANTTYPE, LPVOID, LPFORMATETC, LPPOINTL
, LPSIZEL, LPSTORAGE, LPPATRONOBJECT, DWORD);
BOOL FLoad(LPSTORAGE, LPFORMATETC, LPRECTL);
BOOL FOpen(LPSTORAGE);
void Close(BOOL);
BOOL Update(void);
void Destroy(LPSTORAGE);
void Select(BOOL);
BOOL Activate(DWORD);
void Draw(HDC, DVTARGETDEVICE FAR *, HDC, int, int, BOOL, BOOL);
void Repaint(void);
void Invalidate(void);
void ObjectGet(LPUNKNOWN FAR *);
void FormatEtcGet(LPFORMATETC, BOOL);
void SizeGet(LPSIZEL, BOOL);
void SizeSet(LPSIZEL, BOOL);
void RectGet(LPRECTL, BOOL);
void RectSet(LPRECTL, BOOL);
};
typedef CTenant FAR * LPTENANT;
//Return codes for UCreate
#define UCREATE_FAILED 0
#define UCREATE_GRAPHICONLY 1
#define UCREATE_PLACEDOBJECT 2
typedef struct __far tagTENANTLIST
{
DWORD cTenants;
DWORD dwIDNext;
} TENANTLIST, FAR *LPTENANTLIST;
/*
* Persistent information we need to save for each tenant, which is done
* in the tenant list instead of with each tenant. Since this is a small
* structure it's best not to blow another stream for it (overhead).
*/
typedef struct tagTENANTINFO
{
DWORD dwID;
RECTL rcl;
FORMATETC fe; //Excludes ptd
} TENANTINFO, FAR *LPTENANTINFO;
#define SZSTREAMTENANTLIST "Tenant List"
//End CHAPTER7MOD
/*
* Page class describing an individual page and what things it contains,
* managing an IStorage for us.
*
* A DWORD is used to identify this page as the name of the storage
* is the string form of this ID. If we added a page every second,
* it would take 136 years to overrun this counter, so we can
* get away with saving it persistently. I hope this software is
* obsolete by then.
*/
class __far CPage
{
private:
DWORD m_dwID; //Persistent DWORD identifier
LPSTORAGE m_pIStorage; //Sub-storage for this page.
//CHAPTER7MOD
HWND m_hWnd; //Pages window, same as CPages.
DWORD m_cOpens; //Calls to FOpen.
class CPages FAR *m_pPG; //Pages window
DWORD m_dwIDNext;
DWORD m_cTenants;
HWND m_hWndTenantList; //Listbox that manages our tenant list
UINT m_iTenantCur;
LPTENANT m_pTenantCur;
UINT m_uHTCode; //Last hit-test on mouse move.
UINT m_uSizingFlags; //Restrictions on sizing motion.
BOOL m_fTracking; //Tracking resize?
RECTL m_rclOrg; //Original before tracking
RECTL m_rcl; //Tracking rectangle.
RECTL m_rclBounds; //Boundaries for size tracking.
HDC m_hDC; //Tracking hDC.
protected:
BOOL FTenantGet(UINT, LPTENANT FAR *, BOOL);
BOOL FTenantAdd(UINT, DWORD, LPTENANT FAR *);
LPDATAOBJECT TransferObjectCreate(LPPOINTL);
//PAGEMOUS.CPP
UINT TenantFromPoint(UINT, UINT, LPTENANT FAR *);
//End CHAPTER7MOD
public:
//CHAPTER7MOD
CPage(DWORD, HWND, class CPages FAR *);
//End CHAPTER7MOD
~CPage(void);
DWORD GetID(void);
BOOL FOpen(LPSTORAGE);
void Close(BOOL);
BOOL Update(void);
void Destroy(LPSTORAGE);
//CHAPTER7MOD
UINT GetStorageName(LPSTR);
void Draw(HDC, int, int, BOOL, BOOL);
BOOL TenantCreate(TENANTTYPE, LPVOID, LPFORMATETC
, LPPATRONOBJECT, DWORD);
BOOL TenantDestroy(void);
BOOL TenantClip(BOOL);
BOOL FQueryObjectSelected(HMENU);
//PAGEMOUSE.CPP
BOOL OnLeftDown(UINT, UINT, UINT);
BOOL OnLeftDoubleClick(UINT, UINT, UINT);
BOOL OnLeftUp(UINT, UINT, UINT);
void OnNCHitTest(UINT, UINT);
BOOL OnSetCursor(UINT);
void OnMouseMove(UINT, int, int);
//End CHAPTER7MOD
};
typedef CPage FAR * LPPAGE;
/*
* Structures to save with the document describing the device
* configuration and pages that we have. This is followed by
* a list of DWORD IDs for the individual pages.
*/
typedef struct __far tagDEVICECONFIG
{
DEVMODE dm;
char szDriver[CCHDEVICENAME];
char szDevice[CCHDEVICENAME];
char szPort[CCHDEVICENAME];
} DEVICECONFIG, FAR * LPDEVICECONFIG;
typedef struct __far tagPAGELIST
{
DWORD cPages;
DWORD iPageCur;
DWORD dwIDNext;
} PAGELIST, FAR *LPPAGELIST;
//PAGEWIN.CPP
LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL __export FAR PASCAL AbortProc(HDC, int);
BOOL __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
//CHAPTER7MOD
void RectConvertMappings(LPRECT, HDC, BOOL);
//End CHAPTER7MOD
class __far CPages : public CWindow
{
friend LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
friend BOOL __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
friend class CPage;
friend class CTenant;
protected:
//CHAPTER7MOD
LPPAGE m_pPageCur; //Current page we're viewing
//End CHAPTER7MOD
UINT m_iPageCur;
UINT m_cPages; //Number of pages
HWND m_hWndPageList; //Listbox that manages our page list
HFONT m_hFont; //Page font.
BOOL m_fSystemFont; //Is m_hFont system object?
UINT m_cx; //Usable page size in LOMETRIC
UINT m_cy;
UINT m_xMarginLeft; //Unusable page margins, LOMETRIC
UINT m_xMarginRight;
UINT m_yMarginTop;
UINT m_yMarginBottom;
UINT m_xPos; //Current viewport scroll position.
UINT m_yPos; //both in *PIXELS*
DWORD m_dwIDNext; //Next ID for a page.
LPSTORAGE m_pIStorage; //Root storage of document.
//CHAPTER7MOD
UINT m_cf; //Application clipboard format.
BOOL m_fDirty;
//End CHAPTER7MOD
protected:
void Draw(HDC, BOOL, BOOL);
void UpdateScrollRanges(void);
BOOL ConfigureForDevice(void);
BOOL FPageGet(UINT, LPPAGE FAR *, BOOL);
BOOL FPageAdd(UINT, DWORD, BOOL);
//CHAPTER7MOD
//RectConvertMappings made global.
void CalcBoundingRect(LPRECT, BOOL);
//End CHAPTER7MOD
public:
//CHAPTER7MOD
CPages(HINSTANCE, UINT);
//End CHAPTER7MOD
~CPages(void);
BOOL FInit(HWND, LPRECT, DWORD, UINT, LPVOID);
BOOL FIStorageSet(LPSTORAGE, BOOL, BOOL); //Was ::New previously
BOOL FIStorageUpdate(BOOL);
BOOL Print(HDC, LPSTR, DWORD, UINT, UINT, UINT);
void RectGet(LPRECT);
void RectSet(LPRECT, BOOL);
void SizeGet(LPRECT);
void SizeSet(LPRECT, BOOL);
UINT PageInsert(UINT);
UINT PageDelete(UINT);
UINT CurPageGet(void);
UINT CurPageSet(UINT);
UINT NumPagesGet(void);
BOOL DevModeSet(HGLOBAL, HGLOBAL);
HGLOBAL DevModeGet(void);
//CHAPTER7MOD
BOOL FIsDirty(void);
BOOL DevReadConfig(LPDEVICECONFIG, HDC FAR *);
BOOL TenantCreate(TENANTTYPE, LPVOID, LPFORMATETC
, LPPATRONOBJECT, DWORD);
BOOL TenantDestroy(void);
BOOL TenantClip(BOOL);
BOOL FQueryObjectSelected(HMENU);
//End CHAPTER7MOD
};
typedef CPages FAR * LPCPages;
//Fixed names of streams in the Pages IStorage
#define SZSTREAMPAGELIST "Page List"
#define SZSTREAMDEVICECONFIG "Device Configuration"
#endif //_PAGES_H_